<template>
  <div v-if="user">
    <van-cell title="当前用户" :value="user?.username"/>
    <van-cell title="修改信息" is-link to="/user/update"/>
    <van-cell title="已创建队伍" is-link to="/team/search" @click="toSearch(user.id)"/>
    <van-cell title="已加入队伍" is-link to="/team/alreadyJoin" @click="toSearchJoin(user.id)"/>
  </div >

</template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import {getCurrentUser} from "../services/user.ts";

const user = ref();
const router = useRouter();

onMounted(async () => {
  user.value = await getCurrentUser();
})



const toSearch = (currentValue: number) => {
  router.push({
    path: '/team/search',
    query: {
      currentValue,
    }
  })
}

const toSearchJoin = (currentValue: number) => {
  router.push({
    path: '/team/join',
    query: {
      currentValue,
    }
  })
}


</script>

<style scoped>

</style>